package UnitTest.DataStructureTest.arrayAndListTest.listTest.listReverseTest;

import DataStructure.arrayAndList.list.Nodelj;
import DataStructure.arrayAndList.list.listReverse.ListReverseTwoPosition;
import org.junit.Test;

/**
 * @author liujun
 * @version 1.0
 * @date 2021/12/7
 * @author—Email ljfirst@mail.ustc.edu.cn
 * @blogURL https://blog.csdn.net/ljfirst
 * @description 链表反转
 * 反转从index1 到 index2 之间的数据，区间是 左闭右闭
 */

public class ListReverseTwoPositionTest extends ListReverseDate {

    Nodelj node = new Nodelj();

    @Test
    public void test() {
        test(new ListReverseTwoPosition());
    }

    public void test(ListReverseTwoPosition instance) {
        Nodelj answer = instance.reverse(list01, 3, 5);
        assert node.equals(answer, Nodelj.Array2Nodelj(array01_Reverse_3_5));
        answer = instance.reverse(list02, 3, 5);
        assert node.equals(answer, Nodelj.Array2Nodelj(array02_Reverse_3_5));
        answer = instance.reverse(list03, 3, 5);
        assert node.equals(answer, Nodelj.Array2Nodelj(array03_Reverse_3_5));
        answer = instance.reverse(list04, 3, 5);
        assert node.equals(answer, Nodelj.Array2Nodelj(array04_Reverse_3_5));
        answer = instance.reverse(list05, 3, 5);
        assert node.equals(answer, Nodelj.Array2Nodelj(array05_Reverse_3_5));
        answer = instance.reverse(list06, 3, 5);
        assert node.equals(answer, Nodelj.Array2Nodelj(array06_Reverse_3_5));
        answer = instance.reverse(list07, 3, 5);
        assert node.equals(answer, Nodelj.Array2Nodelj(array07_Reverse_3_5));
        answer = instance.reverse(list08, 3, 5);
        assert node.equals(answer, Nodelj.Array2Nodelj(array08_Reverse_3_5));
        answer = instance.reverse(list09, 3, 5);
        assert node.equals(answer, Nodelj.Array2Nodelj(array09_Reverse_3_5));
        answer = instance.reverse(list15, 1, 2);
        assert node.equals(answer, Nodelj.Array2Nodelj(array15_Reverse_1_2));
        answer = instance.reverse(list16, 1, 100);
        assert node.equals(answer, Nodelj.Array2Nodelj(array16_Reverse_1_100));
        answer = instance.reverse(list17, -1, 2);
        assert node.equals(answer, Nodelj.Array2Nodelj(array17_Reverse__2));
        answer = instance.reverse(list18, 1, 2);
        assert node.equals(answer, Nodelj.Array2Nodelj(array18_Reverse_1_2));
    }
}
